<?php

require_once('../inc/config.php');

$player_id = isset($_GET['playerid'])?$_GET['playerid']:NULL;

$sql = "SELECT u.loginname,u.sfzhm,u.realname,u.audit_flag,
						 p.nickname,p.national,p.current_title,p.id AS player_id,u.is_online,u.total_charge,
						 p.current_level,p.current_exp,p.mp,p.hp,p.bang_id,b.devote,p.pk_mode,
						 (SELECT SUM(count) FROM tb_player_items WHERE player_id = p.id AND bag = 2) as bag_count,
						 (SELECT SUM(count) FROM tb_player_items WHERE player_id = p.id AND bag = 3) as warehouse_count,
						 p.game_cy,p.game_cy_bind,u.charge_cy,
						 p.vip_level,p.vip_valid_time,p.vip_score,
						 m.`name` as map_name,p.mapx,p.mapy,u.last_login_ip,
						 (SELECT online_time FROM tb_ad_player_filter WHERE id = p.id) as online_time,
						 u.login_time,u.logout_time
			FROM tb_player AS p
			LEFT JOIN tb_user AS u ON u.id=p.user_id
			LEFT JOIN tb_bang_playerlist AS b ON b.player_id = p.id
			LEFT JOIN tb_table_map AS m ON m.id = p.mapid
			WHERE p.id = $player_id";
$rs = $db->query($sql);

$player = array();
while($row = $db->fetch_array($rs))
{
	$player = $row;
	$player['audit_flag'] = $row['audit_flag']==1 ? '成年': '未成年';
	$player['is_online'] = $row['is_online']==1 ? '<font color="red">在线</font>': '离线';
	$player['total_charge'] = $row['total_charge']>0 ? 'RMB': '非R';
	$player['vip_level'] = $row['vip_level']>0 ? '是vip': '非vip';
	$player['online_time'] = intval($row['online_time']/60).'小时'.intval($row['online_time']%60).'分钟';
	$player['vip_valid_time'] = $row['vip_level']>0 ? days($row['vip_valid_time'], date(time())): 0;
	$player['is_logined'] = days(date(time()),$row['login_time']) ==0 ? '<font color="blue">今天登陆了</font>':'今天没登陆';
	
}

$T->assign('player',$player);
$T->display('player_status_monitor.html');

